package com.ego.order.controller;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ego.order.po.OrderItem;
import com.ego.order.service.OrderItemService;
import com.ego.common.util.Result;

/**
 * @program: ego
 * @description 订单项信息控制器
 * @author KamTang
 * @date 2022-11-13 11:25:07
 */
@RestController
@RequestMapping("order/orderitem")
public class OrderItemController {

    @Autowired
    private OrderItemService orderItemService;

    /**
     * 信息
     */
    @GetMapping("/get/{id}")
    public Result get(@PathVariable("id") Long id){
		OrderItem orderItem = orderItemService.getById(id);
        return Result.ok().put("orderItem", orderItem);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public Result save(@RequestBody OrderItem orderItem){
		orderItemService.save(orderItem);
        return Result.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public Result update(@RequestBody OrderItem orderItem){
		orderItemService.updateById(orderItem);
        return Result.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody Long[] ids){
		orderItemService.removeByIds(Arrays.asList(ids));
        return Result.ok();
    }

}
